<%@ Page Language="C#" Theme="YUI" AutoEventWireup="true" MaintainScrollPositionOnPostback="true"
    CodeFile="Contacts.aspx.cs" Inherits="Home_Contacts" %>

<%@ Register Src="../UserControls/Menu.ascx" TagName="Menu" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Placement Manager: Contacts</title>
    <link href="../App_Themes/YUI/tabber.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">

/* Optional: Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear. */

document.write('<style type="text/css">.tabber{display:none;}<\/style>');

/*==================================================
  Set the tabber options (must do this before including tabber.js)
  ==================================================*/
var tabberOptions = {

  'cookie':"tabberContacts", /* Name to use for the cookie */

  'onLoad': function(argsObj)
  {
    var t = argsObj.tabber;
    var i;

    /* Optional: Add the id of the tabber to the cookie name to allow
       for multiple tabber interfaces on the site.  If you have
       multiple tabber interfaces (even on different pages) I suggest
       setting a unique id on each one, to avoid having the cookie set
       the wrong tab.
    */
    if (t.id) {
      t.cookie = t.id + t.cookie;
    }

    /* If a cookie was previously set, restore the active tab */
    i = parseInt(getCookie(t.cookie));
    if (isNaN(i)) { return; }
    t.tabShow(i);
    //alert('getCookie(' + t.cookie + ') = ' + i);
  },

  'onClick':function(argsObj)
  {
    var c = argsObj.tabber.cookie;
    var i = argsObj.index;
    //alert('setCookie(' + c + ',' + i + ')');
    setCookie(c, i);
  }
};

/*==================================================
  Cookie functions
  ==================================================*/
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

    </script>

    <script language="javascript" type="text/javascript" src="../scripts/tabber-minimized.js"></script>

    <script language="javascript" type="text/javascript">
    function showToolTip(e,text){ 
      var ToolTip = document.getElementById("ToolTip");
      ToolTip.innerHTML=text; 
      ToolTip.style.left=(e.clientX+15+document.body.scrollLeft)+'px'; 
      ToolTip.style.top=(e.clientY+document.body.scrollTop)+'px'; 
      ToolTip.style.visibility="visible"; 
    } 
    function hideToolTip(){ 
        var ToolTip = document.getElementById("ToolTip");
        ToolTip.style.visibility="hidden"; 
    } 
    function showAddAddress()
    {
        var divAddAddress = document.getElementById("divAddAddress");
        divAddAddress.style.display = "block";
    }
    function hideAddAddress()
    {
        var divAddAddress = document.getElementById("divAddAddress");
        divAddAddress.style.display = "none";
    }
    function showAddContact()
    {
        var divAddContact = document.getElementById("divAddContact");
        divAddContact.style.display = "block";
    }
    function hideAddContact()
    {
        var divAddContact = document.getElementById("divAddContact");
        divAddContact.style.display = "none";
    }
    function showAddNote()
    {
        var divAddContact = document.getElementById("divAddNote");
        divAddContact.style.display = "block";
    }
    function hideAddNote()
    {
        var divAddContact = document.getElementById("divAddNote");
        divAddContact.style.display = "none";
    }
    function showAddresses()
    {
        var divAddresses = document.getElementById("divAddresses");
        divAddresses.style.display = "block";
    }
    function hideAddresses()
    {
        var divAddresses = document.getElementById("divAddresses");
        divAddresses.style.display = "none";
    }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="True">
        </ajaxToolkit:ToolkitScriptManager>
        <div id="ToolTip" style="position: absolute; z-index: 1000; text-align: left; display: none;">
        </div>
        <div id="doc3" class="yui-t1">
            <div id="hd">
                <asp:Panel ID="pnlMenu" runat="server">
                    <uc1:Menu ID="Menu1" runat="server" />
                </asp:Panel>
            </div>
            <div id="bd">
                <div class="yui-b">
                    <asp:UpdatePanel ID="updtpnlContactsGrid" runat="server" UpdateMode="Conditional"
                        ChildrenAsTriggers="true">
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnInsertContact" EventName="Click" />
                        </Triggers>
                        <ContentTemplate>
                            <div style="background-color: #AD8282; width: 155px; padding-left: 3px; padding-right: 3px;
                                padding-bottom: 3px; padding-top: 3px;">
                                <asp:TextBox ID="txtSearchName" runat="server"></asp:TextBox>
                                <asp:ImageButton ID="imgbtnSearch" runat="server" ImageUrl="~/Images/Icons/search.gif"
                                    OnClick="imgbtnSearch_Click" CssClass="SearchImageButton" ImageAlign="AbsMiddle" />
                                <ajaxToolkit:AutoCompleteExtender ID="aceSearchName" EnableCaching="true" MinimumPrefixLength="3"
                                    TargetControlID="txtSearchName" runat="server" ServiceMethod="GetContacts" ServicePath="../WebServices/ContactService.asmx">
                                </ajaxToolkit:AutoCompleteExtender>
                            </div>
                            <asp:GridView ID="gvContacts" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                                DataSourceID="odsContacts" OnSelectedIndexChanged="gvContacts_SelectedIndexChanged"
                                PageSize="18" SelectedIndex="0" SkinID="Results" AllowPaging="True" DataKeyNames="ContactId"
                                OnDataBound="gvContacts_DataBound" Width="160px" OnPageIndexChanged="gvContacts_PageIndexChanged">
                                <Columns>
                                    <asp:CommandField ButtonType="Image" SelectImageUrl="~/Images/Icons/edit.gif" ShowSelectButton="True" />
                                    <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                                    <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                                </Columns>
                                <EmptyDataTemplate>
                                    No contacts Defined.
                                </EmptyDataTemplate>
                            </asp:GridView>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                <div id="yui-main">
                    <div class="yui-b">
                        <span style="font-size: large; font-weight: bold; float: left;">Manage Contacts</span>
                        <asp:UpdateProgress ID="updtprogContactsGrid" runat="server" AssociatedUpdatePanelID="updtpnlContactsGrid"
                            DisplayAfter="2" DynamicLayout="false">
                            <ProgressTemplate>
                                &nbsp;&nbsp;
                                <img alt="Progress" src="../Images/progressbar_long_green.gif" />
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <div class="tabber" id="mainTabset">
                            <div class="tabbertab">
                                <h2>
                                    Contact Details</h2>
                                <div class="yui-g">
                                    <div class="yui-u first">
                                        <asp:UpdatePanel ID="updtpnlContactDetails" runat="server" UpdateMode="Conditional">
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="SelectedIndexChanged" />
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="DataBound" />
                                            </Triggers>
                                            <ContentTemplate>
                                                <asp:FormView ID="fvContact" runat="server" DataSourceID="odsContact" EmptyDataText="There is no contact selected."
                                                    OnItemUpdated="fvContact_ItemUpdated" OnItemUpdating="fvContact_ItemUpdating"
                                                    OnItemCommand="fvContact_ItemCommand" Width="100%">
                                                    <EditItemTemplate>
                                                        <table style="width: 95%; font-size: 0.8em;">
                                                            <tr>
                                                                <td class="formLabel">
                                                                    First Name:</td>
                                                                <td>
                                                                    <asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("FirstName") %>'
                                                                        MaxLength="256" Width="200px"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Last Name:</td>
                                                                <td>
                                                                    <asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("LastName") %>' MaxLength="256"
                                                                        Width="200px"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Title:</td>
                                                                <td>
                                                                    <asp:TextBox ID="TitleTextBox" runat="server" MaxLength="256" Text='<%# Bind("Title") %>'
                                                                        Width="200px"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Email:</td>
                                                                <td>
                                                                    <asp:TextBox ID="EmailAddressTextBox" runat="server" Text='<%# Bind("EmailAddress") %>'
                                                                        MaxLength="256" Width="200px"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Job Title:</td>
                                                                <td>
                                                                    <asp:TextBox ID="JobTitleTextBox" runat="server" Text='<%# Bind("JobTitle") %>' MaxLength="256"
                                                                        Width="200px"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Educator Type:</td>
                                                                <td>
                                                                    <asp:DropDownList ID="ddEditEducatorType" runat="server" DataSourceID="odsEducatorTypes"
                                                                        DataTextField="EducatorTypeName" DataValueField="EducatorTypeId" SelectedValue='<%# Bind("EducatorTypeId") %>'>
                                                                    </asp:DropDownList></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Current Rate:
                                                                </td>
                                                                <td>
                                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("EducatorCurrentRate") %>'
                                                                        MaxLength="256" Width="200px"></asp:TextBox>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                                                            Text="Update">
                                                        </asp:LinkButton>
                                                        <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                                            Text="Cancel">
                                                        </asp:LinkButton>
                                                        <asp:ObjectDataSource ID="odsEducatorTypes" runat="server" OldValuesParameterFormatString="original_{0}"
                                                            SelectMethod="SelectAll" TypeName="PlacementManager.EducatorTypeComponent">
                                                            <SelectParameters>
                                                                <asp:Parameter DefaultValue="EducatorTypeName" Name="sortExpression" Type="String" />
                                                            </SelectParameters>
                                                        </asp:ObjectDataSource>
                                                    </EditItemTemplate>
                                                    <ItemTemplate>
                                                        <span style="font-size: larger;">
                                                            <asp:Label ID="TitleLabel" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                                                            <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
                                                            <asp:Label ID="LastNameLabel" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
                                                        </span>
                                                        <br />
                                                        <asp:Label ID="JobTitleLabel" runat="server" Text='<%# Bind("JobTitle") %>'></asp:Label>
                                                        <table style="width: 95%; font-size: 0.8em;">
                                                            <tr>
                                                                <td class="formLabel" style="width: 130px">
                                                                    Email:
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="EmailAddressLabel" runat="server" Text='<%# Eval("EmailAddress","<a href=mailto:{0}>{0}</a>") %>'></asp:Label>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel" style="width: 130px">
                                                                    Educator Type:</td>
                                                                <td>
                                                                    <asp:Label ID="lblEducatorType" runat="server" Text='<%# GetEducatorType(Eval("EducatorTypeId").ToString()) %>'></asp:Label></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel" style="width: 130px">
                                                                    Current Rate:
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="lblCurrentRate" runat="server" Text='<%# Bind("EducatorCurrentRate","{0:C}") %>'></asp:Label>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                        <asp:Button ID="btnEdit" runat="server" CommandName="Edit" CssClass="inputbutton"
                                                            Text="Edit" />&nbsp;<asp:Button ID="btnDelete" runat="server" CommandName="DeleteContact"
                                                                CssClass="inputbutton" Text="Delete" />
                                                        <ajaxToolkit:ConfirmButtonExtender ID="cbeDeleteContact" runat="server" ConfirmText="Are you sure that you want  to delete this contact?"
                                                            TargetControlID="btnDelete">
                                                        </ajaxToolkit:ConfirmButtonExtender>
                                                    </ItemTemplate>
                                                </asp:FormView>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                        <asp:UpdatePanel ID="updtpnlContactNumbers" runat="server" UpdateMode="Conditional">
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="SelectedIndexChanged" />
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="DataBound" />
                                            </Triggers>
                                            <ContentTemplate>
                                                <span class="formLabel">Contact Numbers</span>
                                                <asp:GridView ID="gvContactNumbers" runat="server" AutoGenerateColumns="False" DataKeyNames="ContactContactNumberId"
                                                    DataSourceID="odsContactNumbers" EmptyDataText="No contact numbers have been added."
                                                    SkinID="Results" OnRowCommand="gvContactNumbers_RowCommand" ShowHeader="False">
                                                    <Columns>
                                                        <asp:ButtonField ButtonType="Image" CommandName="DeleteContactNumber" ImageUrl="~/Images/Icons/x.gif"
                                                            Text="Remove Number" />
                                                        <asp:TemplateField HeaderText="Type">
                                                            <ItemTemplate>
                                                                <asp:Label ID="lblContactNumberType" runat="server" Text='<%# GetContactNumberType(Eval("ContactNumberId").ToString()) %>'></asp:Label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="Number" SortExpression="ContactNumberId">
                                                            <ItemTemplate>
                                                                <asp:Label ID="lblContactNumber" runat="server" Text='<%# GetContactNumber(Eval("ContactNumberId").ToString()) %>'></asp:Label>
                                                            </ItemTemplate>
                                                            <ItemStyle VerticalAlign="Top" />
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                                                <asp:TextBox ID="txtNewContactNumber" runat="server" CssClass="inserttext" MaxLength="50"
                                                    Width="70px"></asp:TextBox>
                                                <asp:DropDownList ID="ddNewContactNumberType" runat="server" CssClass="dropdownlist"
                                                    DataSourceID="odsContactNumberTypes" DataTextField="ContactNumberTypeName" DataValueField="ContactNumberTypeId">
                                                </asp:DropDownList>
                                                <asp:Button ID="btnAddContactNumber" runat="server" CssClass="inputbutton" Text="Add Contact Number"
                                                    OnClick="btnAddContactNumber_Click" />
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                        <asp:UpdatePanel ID="updtpnlAddresses" runat="server" UpdateMode="Conditional">
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="SelectedIndexChanged" />
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="DataBound" />
                                            </Triggers>
                                            <ContentTemplate>
                                                <input id="btnShowAddresses" class="inputbutton" onclick="showAddresses();" type="button"
                                                    value="Show Addresses" />
                                                <div id="divAddresses" style="display: none;">
                                                    <span class="formLabel">Addresses</span>
                                                    <asp:DataList ID="dlAddresses" runat="server" DataKeyField="AddressId" DataSourceID="odsAddresses"
                                                        OnDeleteCommand="dlAddresses_DeleteCommand" OnItemCommand="dlAddresses_ItemCommand"
                                                        RepeatColumns="2" RepeatDirection="Horizontal">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblIsPrimary" runat="server" Text='<%# GetIsPrimaryAddress(Eval("AddressId").ToString()) %>'></asp:Label>
                                                            <asp:Label ID="AddressLabel" runat="server" Text='<%# GetFormattedAddress(Eval("AddressId").ToString()) %>'></asp:Label><br />
                                                            <asp:ImageButton ID="imgbtnDeleteAddress" runat="server" CommandName="Delete" ImageUrl="~/Images/Icons/x.gif"
                                                                ToolTip="Delete" />
                                                            <asp:Button ID="btnMakePrimary" runat="server" CommandName="MakeAddressPrimary" CssClass="inputbutton"
                                                                Text="Make Primary" Visible='<%# ShowMakePrimaryAddressButton(Eval("AddressId").ToString()) %>' />
                                                            <ajaxToolkit:ConfirmButtonExtender ID="cbeDeleteAddress" runat="server" ConfirmText="Are you sure that you want to delete this address?"
                                                                TargetControlID="imgbtnDeleteAddress">
                                                            </ajaxToolkit:ConfirmButtonExtender>
                                                        </ItemTemplate>
                                                        <ItemStyle CssClass="AddressRepeaterItem" VerticalAlign="Top" />
                                                    </asp:DataList>
                                                    <input id="btnHideAddresses" class="inputbutton" onclick="hideAddresses();" type="button"
                                                        value="Hide Addresses" />
                                                    <input id="btnShowAddNewAddress" class="inputbutton" onclick="showAddAddress();"
                                                        type="button" value="Add New Address" />
                                                </div>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                        <div id="divAddAddress" style="display: none;">
                                            <asp:UpdatePanel ID="updtpnlAddNewAddress" runat="server" ChildrenAsTriggers="true"
                                                UpdateMode="Conditional">
                                                <ContentTemplate>
                                                    <fieldset id="fldAddAddress">
                                                        <legend id="lgAddAddress">Add Address</legend>
                                                        <table>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Address1:</td>
                                                                <td>
                                                                    <asp:TextBox ID="txtNewAddress1" runat="server"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Address2:</td>
                                                                <td>
                                                                    <asp:TextBox ID="txtNewAddress2" runat="server"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Street:</td>
                                                                <td>
                                                                    <asp:TextBox ID="txtNewStreet" runat="server"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Country:</td>
                                                                <td>
                                                                    <asp:DropDownList ID="ddNewCountry" runat="server" AutoPostBack="True" DataSourceID="odsCountries"
                                                                        DataTextField="CountryName" DataValueField="CountryID">
                                                                    </asp:DropDownList></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    State:</td>
                                                                <td>
                                                                    <asp:DropDownList ID="ddNewState" runat="server" AutoPostBack="True" DataSourceID="odsStates"
                                                                        DataTextField="DivisionName" DataValueField="AdministrativeDivisionID">
                                                                    </asp:DropDownList>
                                                                    <asp:ObjectDataSource ID="odsStates" runat="server" OldValuesParameterFormatString="original_{0}"
                                                                        SelectMethod="SelectAllWCountryID" TypeName="PlacementManager.Geo_AdministrativeDivisionComponent">
                                                                        <SelectParameters>
                                                                            <asp:ControlParameter ControlID="ddNewCountry" Name="CountryID" PropertyName="SelectedValue"
                                                                                Type="Int32" />
                                                                            <asp:Parameter DefaultValue="DivisionName" Name="sortExpression" Type="String" />
                                                                        </SelectParameters>
                                                                    </asp:ObjectDataSource>
                                                                    <asp:ObjectDataSource ID="odsPossibleLocations" runat="server" OldValuesParameterFormatString="original_{0}"
                                                                        SelectMethod="SelectAllWAdministrativeDivisionIDStartingWith" TypeName="PlacementManager.Geo_LocationComponent">
                                                                        <SelectParameters>
                                                                            <asp:ControlParameter ControlID="txtNewCity" Name="prefix" PropertyName="Text" Type="String" />
                                                                            <asp:ControlParameter ControlID="ddNewState" Name="AdministrativeDivisionID" PropertyName="SelectedValue"
                                                                                Type="Int32" />
                                                                            <asp:Parameter DefaultValue="FullName" Name="sortExpression" Type="String" />
                                                                        </SelectParameters>
                                                                    </asp:ObjectDataSource>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    Town/City:
                                                                </td>
                                                                <td>
                                                                    <asp:TextBox ID="txtNewCity" runat="server"></asp:TextBox>
                                                                    <ajaxToolkit:AutoCompleteExtender ID="aceNewCity" runat="server" BehaviorID="AutoCompleteBehavior"
                                                                        ContextKey="2" ServiceMethod="GetLocationsForState" ServicePath="~/WebServices/Geo_LocationService.asmx"
                                                                        TargetControlID="txtNewCity" UseContextKey="True">
                                                                    </ajaxToolkit:AutoCompleteExtender>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel">
                                                                    PostCode:</td>
                                                                <td>
                                                                    <asp:TextBox ID="txtNewPostCode" runat="server"></asp:TextBox>
                                                                    <asp:ImageButton ID="imgbtnFindPostCode" runat="server" ImageUrl="~/Images/Icons/search.gif"
                                                                        OnClick="imgbtnFindPostCode_Click" ToolTip="Find Post Code" /></td>
                                                            </tr>
                                                            <tr>
                                                                <td colspan="2">
                                                                    <asp:CheckBox ID="cbNewAddressIsPostal" runat="server" Text="Is Postal" />
                                                                    <asp:CheckBox ID="cbNewAddressIsPrimary" runat="server" Text="Is Primary" />
                                                                    <asp:Button ID="btnAddAddress" runat="server" CssClass="inputbutton" OnClick="btnAddAddress_Click"
                                                                        Text="Save Address" />
                                                                    <input id="btnHideAddAddress" class="inputbutton" onclick="hideAddAddress();" type="button"
                                                                        value="Cancel" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </fieldset>
                                                </ContentTemplate>
                                            </asp:UpdatePanel>
                                        </div>
                                        <input id="btnShowAddContact" class="inputbutton" onclick="showAddContact();" type="button"
                                            value="Add New Contact" />
                                        <div id="divAddContact" style="display: none;">
                                            <asp:UpdatePanel ID="updtpnlAddContact" runat="server" ChildrenAsTriggers="true"
                                                UpdateMode="Conditional">
                                                <ContentTemplate>
                                                    <fieldset id="fldAddContact">
                                                        <legend id="lgdAddContact">Add Contact</legend>
                                                        <table style="width: 100%">
                                                            <tr>
                                                                <td class="formLabel" style="width: 100px">
                                                                    Title:</td>
                                                                <td style="width: 183px">
                                                                    <asp:TextBox ID="txtNewContactTitle" runat="server"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="rfvNewContactTitle" runat="server" ControlToValidate="txtNewContactTitle"
                                                                        CssClass="message" ErrorMessage="Please enter a title" ForeColor="" ValidationGroup="valgrpNewContact">*</asp:RequiredFieldValidator></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel" style="width: 100px">
                                                                    First Name:</td>
                                                                <td style="width: 183px">
                                                                    <asp:TextBox ID="txtNewContactFirstName" runat="server"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtNewContactFirstName"
                                                                        CssClass="message" ErrorMessage="Please enter a first name" ForeColor="" ValidationGroup="valgrpNewContact">*</asp:RequiredFieldValidator></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel" style="width: 100px">
                                                                    Last Name:</td>
                                                                <td style="width: 183px">
                                                                    <asp:TextBox ID="txtNewContactLastName" runat="server"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtNewContactLastName"
                                                                        CssClass="message" ErrorMessage="Please enter a last name" ForeColor="" ValidationGroup="valgrpNewContact">*</asp:RequiredFieldValidator></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel" style="width: 100px">
                                                                    Job Title:</td>
                                                                <td style="width: 183px">
                                                                    <asp:TextBox ID="txtNewContactJobTitle" runat="server"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="rfvNewContactJobTitle" runat="server" ControlToValidate="txtNewContactJobTitle"
                                                                        CssClass="message" ErrorMessage="Please enter a job title" ForeColor="" ValidationGroup="valgrpNewContact">*</asp:RequiredFieldValidator></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel" style="width: 100px">
                                                                    Email Address:</td>
                                                                <td style="width: 183px">
                                                                    <asp:TextBox ID="txtNewContactEmail" runat="server"></asp:TextBox>
                                                                    <asp:RegularExpressionValidator ID="revalEmail" runat="server" ControlToValidate="txtNewContactEmail"
                                                                        CssClass="message" ErrorMessage="Please enter a valid email address" ForeColor=""
                                                                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="valgrpNewContact">*</asp:RegularExpressionValidator></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="formLabel" style="width: 100px">
                                                                </td>
                                                                <td style="width: 183px">
                                                                    <asp:Button ID="btnInsertContact" runat="server" CssClass="inputbutton" OnClick="btnInsertContact_Click"
                                                                        Text="Save New Contact" ValidationGroup="valgrpNewContact" />
                                                                    <input id="btnHideAddContact" class="inputbutton" onclick="hideAddContact();" type="button"
                                                                        value="Cancel" /><br />
                                                                    <asp:ValidationSummary ID="valSummaryNewContact" runat="server" CssClass="message"
                                                                        ForeColor="" ValidationGroup="valgrpNewContact" />
                                                                    <br />
                                                                    <asp:Label ID="lblAddNewContactMessage" runat="server" CssClass="message"></asp:Label></td>
                                                            </tr>
                                                        </table>
                                                    </fieldset>
                                                </ContentTemplate>
                                            </asp:UpdatePanel>
                                        </div>
                                    </div>
                                    <div class="yui-u">
                                        <asp:UpdatePanel ID="updtpnlVenues" runat="server" UpdateMode="Conditional">
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="SelectedIndexChanged" />
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="DataBound" />
                                            </Triggers>
                                            <ContentTemplate>
                                                Venues<br />
                                                <asp:GridView ID="gvVenueContacts" runat="server" AutoGenerateColumns="False" DataSourceID="odsContactVenues"
                                                    SkinID="Results" DataKeyNames="VenueContactId" EmptyDataText="This contact is not associated with any venues."
                                                    OnRowCommand="gvVenueContacts_RowCommand" ShowHeader="False">
                                                    <Columns>
                                                        <asp:ButtonField ButtonType="Image" CommandName="DeleteVenueLink" ImageUrl="~/Images/Icons/x.gif"
                                                            Text="Remove Link" />
                                                        <asp:TemplateField HeaderText="Associated Venues" SortExpression="VenueId">
                                                            <ItemTemplate>
                                                                <asp:Label ID="lblVenueName" runat="server" Text='<%# GetVenueName(Eval("VenueId").ToString()) %>'></asp:Label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                                                <asp:TextBox ID="txtVenueName" runat="server"></asp:TextBox>
                                                <asp:Button ID="btnAttachVenue" runat="server" CssClass="inputbutton" Text="Attach Venue"
                                                    OnClick="btnAttachVenue_Click" />
                                                <ajaxToolkit:AutoCompleteExtender ID="aceVenue" runat="server" ServiceMethod="GetVenues"
                                                    ServicePath="../WebServices/VenueService.asmx" TargetControlID="txtVenueName"
                                                    DelimiterCharacters="" Enabled="True">
                                                </ajaxToolkit:AutoCompleteExtender>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                        <asp:UpdatePanel ID="updtpnlAttributes" runat="server" UpdateMode="Conditional">
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="SelectedIndexChanged" />
                                                <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="DataBound" />
                                            </Triggers>
                                            <ContentTemplate>
                                                <span class="formLabel">Contact Attributes</span>
                                                <asp:GridView ID="gvContactAttributes" runat="server" AutoGenerateColumns="False"
                                                    DataSourceID="odsContactAttributes" SkinID="Results" OnRowDataBound="gvContactAttributes_RowDataBound"
                                                    DataKeyNames="ContactAttributeId" ShowHeader="False">
                                                    <Columns>
                                                        <asp:BoundField DataField="AttributeName" HeaderText="Attribute" SortExpression="AttributeName" />
                                                        <asp:TemplateField ShowHeader="False">
                                                            <ItemTemplate>
                                                                <asp:CheckBox ID="cbEditContactAttribute" runat="server" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                                                <asp:Button ID="btnUpdateAttribute" runat="server" CssClass="inputbutton" OnClick="btnUpdateAttribute_Click"
                                                    Text="Update Attributes" />
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </div>
                                </div>
                            </div>
                            <div class="tabbertab">
                                <h2>
                                    Notes</h2>
                                <asp:UpdatePanel ID="updtpnlNotes" runat="server" UpdateMode="Conditional">
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="SelectedIndexChanged" />
                                        <asp:AsyncPostBackTrigger ControlID="gvContacts" EventName="DataBound" />
                                        <asp:AsyncPostBackTrigger ControlID="btnSaveNote" EventName="Click" />
                                    </Triggers>
                                    <ContentTemplate>
                                        <asp:GridView ID="gvNotes" runat="server" AutoGenerateColumns="False" DataKeyNames="NoteId"
                                            DataSourceID="odsComments" EmptyDataText="No notes have been added for this contact."
                                            OnRowCommand="gvNotes_RowCommand" OnRowUpdating="gvNotes_RowUpdating" ShowHeader="False"
                                            SkinID="Notes" Width="90%">
                                            <Columns>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <hr style="height: 1px" />
                                                        <p>
                                                            Created On:
                                                            <asp:Label ID="lblCommentDateCreated" runat="server" Text='<%# Bind("DateCreated") %>'></asp:Label>
                                                            By:
                                                            <asp:Label ID="lblCommentCreatedBy" runat="server" Text='<%# Bind("CreatedBy") %>'></asp:Label>
                                                            <br />
                                                            Last Updated On:
                                                            <asp:Label ID="lblCommentDateUpdated" runat="server" Text='<%# Bind("DateUpdated") %>'></asp:Label>
                                                            By:
                                                            <asp:Label ID="lblCommentUpdatedBy" runat="server" Text='<%# Bind("UpdatedBy") %>'></asp:Label>
                                                        </p>
                                                        <br />
                                                        Comment:
                                                        <asp:Label ID="lblComment" runat="server" Text='<%# Bind("NoteText") %>'></asp:Label>
                                                        <br />
                                                        <asp:LinkButton ID="lbEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                                                        <asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%# Bind("NoteId") %>'
                                                            CommandName="DeleteNote">Delete</asp:LinkButton>
                                                        <ajaxToolkit:ConfirmButtonExtender ID="cbeDeleteNote" runat="server" ConfirmText="Are you sure that you want to delete this note?"
                                                            TargetControlID="lbDelete">
                                                        </ajaxToolkit:ConfirmButtonExtender>
                                                    </ItemTemplate>
                                                    <EditItemTemplate>
                                                        <asp:TextBox ID="txtEditNote" runat="server" Height="80px" MaxLength="8000" Text='<%# Bind("NoteText") %>'
                                                            TextMode="MultiLine" Width="90%"></asp:TextBox><br />
                                                        <asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update">Update</asp:LinkButton>
                                                    </EditItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                                <br />
                                <input id="btnShowAddNewNote" class="inputbutton" onclick="showAddNote();" type="button"
                                    value="Add New Note" />
                                <div id="divAddNote" style="display: none;">
                                    <fieldset id="fldAddNote">
                                        <legend id="lgdAddNote">Add Note</legend>
                                        <asp:UpdatePanel ID="updtpnlNewNote" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
                                            <ContentTemplate>
                                                <asp:TextBox ID="txtAddNewNote" runat="server" Height="80px" MaxLength="8000" TextMode="MultiLine"
                                                    Width="90%"></asp:TextBox><br />
                                                <asp:Button ID="btnSaveNote" runat="server" CssClass="inputbutton" OnClick="btnSaveNote_Click"
                                                    Text="Save Note" />
                                                <input id="btnHideAddNote" class="inputbutton" onclick="hideAddNote();" type="button"
                                                    value="Cancel" />
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </fieldset>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="ft">
                &nbsp;
            </div>
        </div>
        <!--
    ********************************************************************* 
    Object Data Sources 
    ********************************************************************* 
    -->
        <asp:ObjectDataSource ID="odsContacts" runat="server" SelectMethod="SelectAllActiveStartingWith"
            SortParameterName="sortExpression" TypeName="PlacementManager.ContactComponent"
            OldValuesParameterFormatString="original_{0}" DeleteMethod="DeleteAllWDivisionId">
            <SelectParameters>
                <asp:SessionParameter Name="DivisionId" SessionField="DivisionId" Type="Int32" />
                <asp:ControlParameter ControlID="txtSearchName" Name="prefix" PropertyName="Text"
                    Type="String" />
                <asp:Parameter DefaultValue="LastName" Name="sortExpression" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="DivisionId" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsContact" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectOne" TypeName="PlacementManager.ContactComponent" UpdateMethod="Update"
            DataObjectTypeName="PlacementManager.Contact">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvContacts" DefaultValue="1" Name="ContactId" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsSingleContact" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectOne" TypeName="PlacementManager.ContactComponent">
            <SelectParameters>
                <asp:QueryStringParameter Name="ContactId" QueryStringField="id" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsContactAttributes" runat="server" DataObjectTypeName="PlacementManager.ContactAttribute"
            DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllWDivisionId" TypeName="PlacementManager.ContactAttributeComponent"
            UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="ContactAttributeId" Type="Int32" />
            </DeleteParameters>
            <SelectParameters>
                <asp:SessionParameter Name="divisionId" SessionField="DivisionId" Type="Int32" />
                <asp:Parameter DefaultValue="DateCreated" Name="sortExpression" Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="DivisionId" Type="Int32" />
                <asp:Parameter Name="AttributeName" Type="String" />
                <asp:Parameter Name="IsActive" Type="Boolean" />
                <asp:Parameter Name="DateCreated" Type="DateTime" />
                <asp:Parameter Name="CreatedBy" Type="String" />
                <asp:Parameter Name="DateUpdated" Type="DateTime" />
                <asp:Parameter Name="UpdatedBy" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsCountries" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
            OldValuesParameterFormatString="original_{0}" SelectMethod="SelectAllWDisplay"
            TypeName="PlacementManager.Geo_CountryComponent" UpdateMethod="Update">
            <SelectParameters>
                <asp:Parameter DefaultValue="CountryName" Name="sortExpression" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="CountryID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="CountryID" Type="Int32" />
                <asp:Parameter Name="CountryName" Type="String" />
                <asp:Parameter Name="CountryCode" Type="String" />
                <asp:Parameter Name="SubDivisionSingularName" Type="String" />
                <asp:Parameter Name="SubDivisionPluralName" Type="String" />
                <asp:Parameter Name="Display" Type="Boolean" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="CountryName" Type="String" />
                <asp:Parameter Name="CountryCode" Type="String" />
                <asp:Parameter Name="SubDivisionSingularName" Type="String" />
                <asp:Parameter Name="SubDivisionPluralName" Type="String" />
                <asp:Parameter Name="Display" Type="Boolean" />
            </InsertParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsContactVenues" runat="server" DataObjectTypeName="PlacementManager.LinkVenueContact"
            DeleteMethod="Delete" OldValuesParameterFormatString="original_{0}" SelectMethod="SelectAllWContactId"
            TypeName="PlacementManager.LinkVenueContactComponent">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvContacts" Name="ContactId" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="VenueName" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsContactNumberTypes" runat="server" DeleteMethod="Delete"
            InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="SelectAll"
            TypeName="PlacementManager.ContactNumberTypeComponent" UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="ContactNumberTypeId" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ContactNumberTypeId" Type="Int32" />
                <asp:Parameter Name="ContactNumberTypeName" Type="String" />
            </UpdateParameters>
            <SelectParameters>
                <asp:Parameter DefaultValue="ContactNumberTypeId" Name="sortExpression" Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="ContactNumberTypeName" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsContactNumbers" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllWContactId" TypeName="PlacementManager.LinkContactContactNumberComponent"
            DeleteMethod="DeleteAllWContactNumberId">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvContacts" Name="ContactId" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="ContactContactNumberId" Name="sortExpression" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="ContactNumberId" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsComments" runat="server" DataObjectTypeName="PlacementManager.Note"
            DeleteMethod="DeleteAllWNoteTypeId" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllWNoteTypeIdEntityId" TypeName="PlacementManager.NoteComponent"
            UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="NoteTypeId" Type="Int32" />
            </DeleteParameters>
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="NoteTypeId" Type="Int32" />
                <asp:ControlParameter ControlID="gvContacts" DefaultValue="" Name="EntityId" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="DateCreated" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsAddresses" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="SelectAllForContact" TypeName="PlacementManager.AddressComponent">
            <SelectParameters>
                <asp:ControlParameter ControlID="gvContacts" Name="ContactId" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="Address1" Name="sortExpression" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </form>
</body>
</html>
